package cn.edu.scau.cmi.xuwenlong.Hibernate;

import java.awt.TextArea;
import java.util.Random;

public class HibernateController {

    public TextArea cmdView1;
    private static StudentTest studentTest = new StudentTest();
    public static int count = 1;


    public void osSwitch(){

    }

    public void osCreate(){
        cmdView1.setText(studentTest.createStudent(count++)+"\n");
    }

    public void osDelete(){
        Random random = new Random();
        int id = (random.nextInt(count)%count);
        if (id == 0)
            id++;
        System.err.println(id);
        cmdView1.setText(studentTest.deleteStudent(id)+"\n");
    }

    public void osUpdate(){
        Random random = new Random();
        int id = (random.nextInt(count)%count);
        if (id == 0)
            id++;
        System.err.println(id);
        cmdView1.setText(studentTest.updateStudent(id)+"\n");
    }

    public void osSelect(){
     cmdView1.setText(studentTest.selectStudnet());
    }

    public void executeCMD() {

    }

    public void onclickComboBox() {

    }
}